<div class="da-list-wrap">
  <div class="da-content-banner">
    <d-breadcrumb>
      <d-breadcrumb-item><a routerLink="/">{{ 'basicdata.breadcrumb.home' | translate }}</a></d-breadcrumb-item>
      <d-breadcrumb-item>采购质检单</d-breadcrumb-item>
    </d-breadcrumb>
  </div>
  <div class="da-content-wrapper">
    <div class="da-list-container">
      <div class="da-list-header">
        <div class="d-input">
          <div class="inputIn">
            <input dTextInput style="width: 180px;" [error]="false" placeholder="采购质检单" name="采购质检单"
              [(ngModel)]="fifter.PurchaseInspectionOrderNum">
            <d-range-datepicker-pro name="制单日期" [placeholder]="['制单日期：起始','制单日期：截止']" [(ngModel)]="date"
              (ngModelChange)="dateChange()"></d-range-datepicker-pro>
            <input dTextInput style="width: 180px;" [error]="false" placeholder="物料编码/物料名称" name="物料名称/编码"
              [(ngModel)]="fifter.Part">
            <!-- <d-select [placeholder]="'单据状态'" name='单据状态' [(ngModel)]="fifter.Status" [options]="statusOptions">
            </d-select> -->
          </div>
          <div class="d-submit">
            <d-button id="primaryBtn" style="margin-left: 8px" (btnClick)="filter2()">
              <i class="icon icon-filter-o me-2"></i>查询
            </d-button>
            <d-button bsStyle="common" (btnClick)="reset()"> <i class="icon icon-refresh me-2"></i>重置</d-button>
          </div>
        </div>
        <div class="btn-group">
          <div class="btn-left">
            <!-- <d-button bsStyle="danger" (btnClick)="delete()"> <i
                    class="icon icon-code-editor-close me-2"></i>删除</d-button> -->
            <!-- <d-button bsStyle="common" (btnClick)="launchReview()"><span
                      class="me-2">发起审核</span></d-button> -->
            <d-button bsStyle="common" (btnClick)="allLog()">日志</d-button>
          </div>
        </div>
      </div>
      <div class="list-content">
        <d-data-table [dataSource]="tableData" [lazy]="true" [scrollable]="true" [fixHeader]="true"
          [tableWidthConfig]="tableWidthConfig" [tableOverflowType]="'auto'" [scrollable]="true"
          (checkAllChange)="getCheckedRows();getCheckedRowsData() "
          (rowCheckChange)="getCheckedRows();getCheckedRowsData()" [resizeable]="true">
          <thead dTableHead [checkable]="true">
            <tr dTableRow>
              <th dHeadCell *ngFor="let colOption of dataTableOptions.columns" [fixedLeft]="colOption.fixedLeft">{{
                    colOption.header }}</th>
            </tr>
          </thead>
          <tbody dTableBody>
            <ng-template let-rowItem="rowItem" let-rowIndex="rowIndex" let-nestedIndex="nestedIndex">
              <tr dTableRow (click)="showDetail(rowItem,rowIndex)"
                [ngClass]="{'selected-row': rowIndex === selectedRowIndex}">
                <td dTableCell [fixedLeft]="'0px'">
                  <d-checkbox [disabled]="false" [showAnimation]="true" [ngModelOptions]="{ standalone: true }"
                    [ngModel]="rowItem.$checked" dTooltip [halfchecked]="rowItem.$halfChecked" [showGlowStyle]="false"
                    (ngModelChange)="onRowCheckChange($event, rowIndex, nestedIndex, rowItem)">
                  </d-checkbox>
                </td>
                <td dTableCell [rowItem]="rowItem" [fixedLeft]="'80px'">
                  <!-- <span><a class="devui-link ms-3" (click)="clickCode(rowItem.purchaseInspectionOrderNum,'采购质检单审核',rowItem.status)"  [class.disabled]="rowItem.status == '未开始审核'">审核</a></span> -->
                  <span>
                    <a class="devui-link " [class.disabled]="rowItem.qualifiedQuantity !== null || rowItem.unqualifiedQuantity !== null"
                      (click)="clickCode(rowItem,'检验')">检验</a>
                  </span>
                  <span>
                    <a class="devui-link ms-3"
                      (click)="clickCode2(rowItem,'查看')" [class.disabled]="rowItem.qualifiedQuantity == null || rowItem.unqualifiedQuantity == null">查看质检单</a>
                  </span>
                  <!-- <span class="ms-3"><a class="devui-link-danger" [class.disabled]="rowItem.status == '审核通过' || rowItem.status =='审核中'"
                          (click)="delete(rowItem.purchaseInspectionOrderId)">删除</a></span> -->
                </td>
                <td dTableCell [rowItem]="rowItem" [field]="'showType'" [fixedLeft]="'350px'">
                  <span dTooltip
                    [content]="rowItem.purchaseInspectionOrderNum">{{rowItem.purchaseInspectionOrderNum}}</span>
                </td>
                <td dTableCell [rowItem]="rowItem" [field]="'showType'">
                  <span dTooltip [content]="rowItem.partName">{{rowItem.partName}}</span>
                </td>
                <td dTableCell [rowItem]="rowItem" [field]="'showType'">
                  <span dTooltip [content]="rowItem.partNum">{{rowItem.partNum}}</span>
                </td>
                <td dTableCell [rowItem]="rowItem" [field]="'showType'">
                  <span dTooltip [content]="rowItem.inspectionQuantity">{{rowItem.inspectionQuantity}}</span>
                </td>
                <td dTableCell [rowItem]="rowItem" [field]="'showType'">
                  <span dTooltip [content]="rowItem.qualifiedQuantity">{{rowItem.qualifiedQuantity}}</span>
                </td>
                <td dTableCell [rowItem]="rowItem" [field]="'showType'">
                  <span dTooltip [content]="rowItem.unqualifiedQuantity">{{rowItem.unqualifiedQuantity}}</span>
                </td>
                <td dTableCell [rowItem]="rowItem" [field]="'showType'">
                  <span>
                    <div dImagePreview>
                      <d-badge *ngIf="rowItem.image" [count]="getImagesArray(rowItem.image).length" status="success">
                        <ng-container *ngFor="let imageUrl of getImagesArray(rowItem.image); let i = index">
                          <img *ngIf="getImagesArray(rowItem.image).length > 0" [src]="imageUrl" alt="图片" height="22px"
                            [ngStyle]="{'display': i === 0 ? 'block' : 'none'}" />
                        </ng-container>
                      </d-badge>
                    </div>
                  </span>
                </td>
                <td dTableCell [rowItem]="rowItem" [field]="'showType'">
                  <span dTooltip [content]="rowItem.partType">{{rowItem.partType}}</span>
                </td>
                <td dTableCell [rowItem]="rowItem" [field]="'showType'">
                  <span dTooltip [content]="rowItem.description">{{rowItem.description}}</span>
                </td>
                <td dTableCell [rowItem]="rowItem" [field]="'showType'">
                  <span dTooltip [content]="rowItem.partUOM">{{rowItem.partUOM}}</span>
                </td>
                <td dTableCell [rowItem]="rowItem" [field]="'showType'">
                  <span dTooltip [content]="rowItem.supplyShortName">{{rowItem.supplyShortName}}</span>
                </td>
                <td dTableCell [rowItem]="rowItem" [field]="'showType'">
                  <span dTooltip [content]="rowItem.supplyChineseName">{{rowItem.supplyChineseName}}</span>
                </td>

                <td dTableCell [rowItem]="rowItem" [field]="'showType'">
                  <span dTooltip [content]="rowItem.warehouseName">{{rowItem.warehouseName}}</span>
                </td>
                <td dTableCell [rowItem]="rowItem" [field]="'showType'">
                  <span dTooltip [content]="rowItem.positionName">{{rowItem.positionName}}</span>
                </td>
                <td dTableCell [rowItem]="rowItem" [field]="'showType'">
                  <span dTooltip [content]="rowItem.purchaseArrivalOrderNum">{{rowItem.purchaseArrivalOrderNum}}</span>
                </td>
                <td dTableCell [rowItem]="rowItem" [field]="'showType'">
                  <span dTooltip [content]="rowItem.inspectionDate">{{rowItem.inspectionDate}}</span>
                </td>
                <td dTableCell [rowItem]="rowItem" [field]="'showType'">
                  <span>
                    <div dImagePreview>
                      <d-badge *ngIf="rowItem.qrCode" [count]="getImagesArray2(rowItem.qrCode).length"
                        status="success">
                        <ng-container *ngFor="let imageUrl of getImagesArray2(rowItem.qrCode); let i = index">
                          <img *ngIf="getImagesArray2(rowItem.qrCode).length > 0" [src]="imageUrl" alt="图片"
                            height="22px" [ngStyle]="{'display': i === 0 ? 'block' : 'none'}" />
                        </ng-container>
                      </d-badge>
                    </div>
                  </span>
                </td>
                <td dTableCell [rowItem]="rowItem" [field]="'showType'">
                  <span dTooltip [content]="rowItem.note">{{rowItem.note}}</span>
                </td>
                <td dTableCell [rowItem]="rowItem" [field]="'showType'">
                  <span (click)="GetLogsById(rowItem.purchaseInspectionOrderId)"><a class="devui-link">日志</a></span>
                </td>
                <!-- <td [fixedRight]="'0px'" dTableCell [rowItem]="rowItem" [field]="'showType'">
                      <span><d-tag [tag]="rowItem.status" [labelStyle]="rowItem.status"></d-tag></span>
                    </td> -->
              </tr>
            </ng-template>
          </tbody>
        </d-data-table>
      </div>
      <div class="page-footer">
        <div>
          <p>已选 <span class="underline">{{checkedIds.length}}</span> 条
            <a (click)="cleared()" class="cleared">清空</a>
          </p>
        </div>
        <d-pagination [size]="'sm'" [canViewTotal]="true" [canChangePageSize]="true" [canJumpPage]="true" [maxItems]="5"
          [total]="this.pager.total" [pageSizeOptions]="this.pageSizeOptions" [(pageSize)]="fifter.PageSize"
          [(pageIndex)]="fifter.PageNumber" (pageIndexChange)="pageIndexChange($event)"
          (pageSizeChange)="pageSizeChange($event)">
        </d-pagination>
      </div>
    </div>


  </div>
</div>
<d-toast [value]="msgs" [life]="2000" [styleClass]="'custom-class'" [style]="{ left: '50%',top:'10px' }"></d-toast>
